from __future__ import division
from myro import *


def findWhite(img):

    img1 = makePicture(img)
    show(img1)
    width = getWidth(img1)
    height = getHeight(img1)

    startWidth = width/2
    startHeight = height/2
   
    white = makeColor(255, 255, 255)
    isWhite = True
    countWhiteY = 0
    countWhiteX = 0
    

    while(isWhite):
        pixel = getPixel(img1, startWidth, countWhiteY)
        print getColor(pixel)
        if(pixel == white):
            countWhiteY += 1
        else:
            isWhite = False
            countWhiteY += 1

    isWhite = True

    while(isWhite):
        pixel = getPixel(img1, countWhiteX, startHeight)
        print getColor(pixel)
        if(pixel == white):
            countWhiteX += 1
        else:
            isWhite = False
            countWhiteX += 1

    fullHeight = countWhiteY * 2
    fullWidth = countWhiteX * 2

    partWidth = width - fullWidth
    partHeight = height - fullHeight

    fractionW = partWidth/width
    fractionH = partHeight/height
    
    print "startWidth: " + str(startWidth)
    print "startHeight: " + str(startHeight)
    print "fullHeight: " + str(fullHeight)
    print "fullWidth: " + str(fullWidth)
    print "partWidth: " + str(partWidth)
    print "partHeight: " + str(partHeight)
    print "countWhiteY: " + str(countWhiteY)
    print "countWhiteX: " + str(countWhiteX)
    print "fractionW: " + str(fractionW)
    print "fractionH: " + str(fractionH)

    if(fractionW != fractionH):
        return False
    else:
        print fractionW
        
